﻿using System;
using UnityEngine;

namespace ZWFrameWork
{
    public class GameUtilty
    {
        public static string showText = "";

        /// 正常打印
        /// </summary>
        public static void Info(string content, params object[] obj)
        {
            if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content))
            {
                Error("content is null or empty");
                return;
            }

            content = "<color=#802A2A>" + content + "</color>";
            for (int index = 0; index < obj.Length; index++)
            {
                obj[index] = "<color=#0000CD>" + obj[index] + "</color>";
            }


            showText = showText + "\n" + DateTime.Now + ":" + String.Format(content, obj);
            Debug.Log(String.Format(content, obj));
        }

        /// <summary>
        /// 错误打印（逻辑错误）
        /// </summary>
        public static void Error(string content, params object[] obj)
        {
            if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content))
            {
                Error("content is null or empty");
                return;
            }

            content = "<color=#FF0000>" + content + "</color>";
            for (int index = 0; index < obj.Length; index++)
            {
                obj[index] = "<color=#0000CD>" + obj[index] + "</color>";
            }

            showText = showText + "\n" + DateTime.Now + ":" + String.Format(content, obj);
            Debug.Log(String.Format(content, obj));
        }

        /// <summary>
        /// 打印byte
        /// </summary>
        /// <param name="content"></param>
        /// <param name="bytes"></param>
        public static void InfoByte(string content,params byte[] bytes)
        {
            if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content))
            {
                Error("content is null or empty");
                return;
            }
            content = "<color=#FF0000>" + content + "</color>";
            string str = "<color=#0000CD>" + BitConverter.ToString(bytes) + "</color> ";
            showText = showText + "\n"+DateTime.Now+":"+String.Format(content, str);
            Debug.Log(String.Format(content,str));
        }
    }
}